//
// Created by 95233 on 2024/4/30.
//

#include "Man.h"
#include <iostream>
#include <graphics.h>

using namespace std;

void Man::init(Chess *chess) {
    this->chess = chess;
}

void Man::go() {
    MOUSEMSG msg;
    ChessPos pos;
    while (true) {
        // 获取鼠标点击消息
        msg = GetMouseMsg();
        // 通过chess对象，来调用，判断落子是否有效
        if (msg.uMsg == WM_LBUTTONDOWN && chess->clickBoard(msg.x, msg.y, &pos)) {// 左键单击，有效点击（未点击到棋盘外部）
            cout << "用户鼠标点击成功，落子成功！" << endl;
            break;
        }
    }
    // 落子
    chess->chessDown(&pos, CHESS_BLACK);
}


